package cc.magicjson.entity;

import cc.magicjson.jpa.repository.UserRepository;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.persistence.PrePersist;

/**
 * {@link}
 *
 * @author <a href="mailto:it_magicjson@163.com">MagicJson</a>
 * @since 1.0.0
 */

@Component
public class MyEntityListener {

//    private final UserRepository userRepository;
//
//    public MyEntityListener(UserRepository userRepository) {
//        this.userRepository = userRepository;
//    }

    @Autowired
    private  UserRepository userRepository;

    @PrePersist
    public void prePersist(User user){
        System.err.println("===========PrePersist PrePersist=========");
        System.err.println(userRepository);
    }

    @PostConstruct
    public void pre(){
        System.err.println("===========PostConstruct PrePersist=========");
        System.err.println(userRepository);
    }
}
